home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH05 / PROJ5_1.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-02-03  |  3.1 KB  |  182 lines

  1. ; Project #1 for Chapter Five
  2. ; This program will fill the screen with a specified set of values
  3. ; when you run it.  Currently, this program is incomplete.  Please
  4. ; read the comments carefully to determine where to insert your code
  5. ; into this program.
  6.  
  7.  
  8.         .386
  9.         option        segment:use16
  10.  
  11.         .xlist
  12.         include     stdlib.a
  13.         includelib    stdlib.lib
  14.         .list
  15.  
  16.  
  17.  
  18. ; Ignore all the stuff between the following two lines containing asterisks
  19. ;
  20. ;****************************************************************************
  21. ;
  22. ; For Loop Support macros  (See Chapter Seven for a description of how
  23. ; these macros work).
  24.  
  25.  
  26.  
  27. ForLp        macro    LCV, start, stop    ;LCV="Loop Ctrl Var"
  28.         local    ForLoop
  29.  
  30.         ifndef    $$For&LCV&
  31. $$For&LCV&    =    0
  32.         else
  33. $$For&LCV&    =    $$For&LCV& + 1
  34.         endif
  35.  
  36. ;; Emit the instructions to initialize the loop control variable.
  37.  
  38.         mov    ax, Start
  39.         mov    LCV, ax
  40.  
  41. ;; Output Loop Label:
  42.  
  43. ForLoop        catstr    <$$For&LCV&>, %$$For&LCV&
  44. &ForLoop&:
  45.  
  46. ;; Output test to see if the loop is done:
  47.  
  48.         mov    ax, LCV
  49.         cmp    ax, Stop
  50.         jg    @catstr(<$$Next&LCV&>, %$$For&LCV&)
  51.         endm
  52.  
  53.  
  54.  
  55.  
  56. ; Here is the NEXT macro:
  57.  
  58.  
  59. Next        macro    LCV
  60.         local    ForDone
  61.  
  62.         inc    LCV
  63.         jmp    @catstr(<$$For&LCV&>, %$$For&LCV&)
  64. ForDone        catstr    <$$Next&LCV&>, %$$For&LCV&
  65. &ForDone&:
  66.         endm
  67.  
  68. ;****************************************************************************
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. ; Okay, here's where your stuff goes:
  80.  
  81.  
  82. dseg        segment    para public 'data'
  83.  
  84. ; Insert declarations for the 16-bit integer variables I and J here.
  85.  
  86.  
  87.  
  88. dseg        ends
  89.  
  90.  
  91.  
  92.  
  93.  
  94. cseg        segment    para public 'code'
  95.         assume    cs:cseg, ds:dseg
  96.  
  97.  
  98.  
  99.  
  100. ; Here's the procedure you need to modify.  On entry, AX contains a word
  101. ; to write to display[i,j].  Compute this index in BX and write the value
  102. ; in AX to location ES:[bx] (the base address is es:0).  Note: the display
  103. ; array is defined as follows  DISPLAY: array [0..24, 0..79] of word.  The
  104. ; I and J variables are both words.
  105.  
  106. PutScreen    proc
  107.         push    es
  108.         mov    bx, 0b800h    ;Change to 0b000h for mono displays.
  109.         mov    es, bx
  110.  
  111.  
  112. ;****************************************************************************
  113. ;
  114. ; Put your code that stores AX at location display[i,j] here.
  115. ; Remember, the base address of array display is es:0.
  116. ;
  117. ; Be sure to use row major ordering.
  118.  
  119.  
  120.  
  121. ; End of your code.
  122. ;
  123. ;****************************************************************************
  124.  
  125.         pop    es
  126.         ret
  127. PutScreen    endp
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. ; This is the main program that calls the procedure above (that you should
  139. ; have modified).  You shouldn't need to modify this code at all.
  140.  
  141. Main        proc
  142.         mov    ax, dseg
  143.         mov    ds, ax
  144.         mov    es, ax
  145.         meminit
  146.  
  147.  
  148.         forlp    j,0,79
  149.         forlp    i,0,24
  150.  
  151.         mov    ax, 500h+"."    ;Colored periods
  152.         call    putscreen
  153.  
  154.         next    i
  155.         next    j
  156.  
  157.         getc            ;Pause by reading the keyboard.
  158.  
  159.         forlp    j,0,79
  160.         forlp    i,0,24
  161.  
  162.         mov    ax, 1000h+" "    ;Blue spaces.
  163.         call    Putscreen
  164.  
  165.         next    i
  166.         next    j
  167.  
  168.  
  169. Quit:        ExitPgm            ;DOS macro to quit program.
  170. Main        endp
  171.  
  172. cseg        ends
  173.  
  174. sseg        segment    para stack 'stack'
  175. stk        byte    1024 dup ("stack   ")
  176. sseg        ends
  177.  
  178. zzzzzzseg    segment    para public 'zzzzzz'
  179. LastBytes    byte    16 dup (?)
  180. zzzzzzseg    ends
  181.         end    Main
  182.